// TypeScript file
class SoundUtils
{
    private static mInstance: SoundUtils;
    /*
    private bgSound: SoundBase;
    private winSound: SoundBase;
    private missSound: SoundBase;
    private hitSound: SoundBase;
    private goSound: SoundBase;
    private overSound: SoundBase;
    private beHitSount: SoundBase;
    private numSound: SoundBase;
    */
    private sounds:Array<SoundBase>;

    public static instance(): SoundUtils
    {
        if (null == this.mInstance)
        {
            this.mInstance = new SoundUtils();
        }
        return this.mInstance;
    }

    constructor()
    {
        if (null != SoundUtils.mInstance)
        {
            throw new Error("singleton");
        }
    }

    public initSound(): void
    {
        this.sounds = [];
        this.sounds[SoundType.BGSOUND] = new SoundBase("sound_bg_mp3");
        this.sounds[SoundType.WINSOUND] = new SoundBase("sound_win_mp3");
        this.sounds[SoundType.MINSSSOUND] = new SoundBase("sound_miss_mp3");
        this.sounds[SoundType.HITSOUND] = new SoundBase("sound_hit_mp3");
        this.sounds[SoundType.GOSOUND] = new SoundBase("sound_go_mp3");
        this.sounds[SoundType.OVERSOUND] = new SoundBase("sound_gameover_mp3");
        this.sounds[SoundType.BEHITSOUND] = new SoundBase("sound_behit_mp3");
        this.sounds[SoundType.NUMSOUND] = new SoundBase("OneTwoThree_mp3");
        
    }

    public play(t: number): void
    {
        if (t > SoundType.MAX || t < SoundType.MIN)
        {
            return;
        }
        if (GameData.closeMusic) return;
        this.sounds[t].play();
    }

    public stop(t: number): void
    {
        if (t > SoundType.MAX || t < SoundType.MIN)
        {
            return;
        }
        this.sounds[t].pause();
    }
    /*
    public playNum(): void
    {
        if (GameData.closeMusic) return;
        this.numSound.play();
    }

    public playBeHit(): void
    {
        if (GameData.closeMusic) return;
        this.beHitSount.play();
    }

    public playOver(): void
    {
        if (GameData.closeMusic) return;
        this.overSound.play();
    }

    public playGo(): void
    {
        if (GameData.closeMusic) return;
        this.goSound.play();

    }

    public playHit(): void
    {
        if (GameData.closeMusic) return;
        this.hitSound.play();
    }

    public playMiss(): void
    {
        if (GameData.closeMusic) return;
        this.missSound.play();
    }

    public playWin(): void
    {
        if (GameData.closeMusic) return;
        this.winSound.play();
    }
    */


}